<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增住户申请</title>
    <link rel="stylesheet" href="/pear/component/layui/css/layui.css">
    <script src="/pear/component/layui/layui.js"></script>
</head>
<body>
<form class="layui-form" action="" style="margin-right: 15px">
    <div class="layui-form-item" style="margin-top: 30px">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text"lay-verify="required" id="userName" placeholder="请填写用户名"  autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">邮 箱</label>
        <div class="layui-input-block">
            <input type="text" id="email" class="layui-input" placeholder="请输入邮箱" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性 别</label>
        <div class="layui-input-block">
            <input type="radio" name="sex" value="1" title="男" checked>
            <input type="radio" name="sex" value="2" title="女">
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">地 址</label>
        <div class="layui-input-block">
            <input type="text" id="address" class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系方式</label>
        <div class="layui-input-block">
            <input type="text" id="phone" class="layui-input" autocomplete="off">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">区域经理</label>
        <div class="layui-input-block">
            <input type="text" id="manager" readonly value="Alien" class="layui-input" autocomplete="off">
        </div>
    </div>

</form>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button class="layui-btn" lay-submit id="submit" lay-filter="formDemo1">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</div>
<script>

    layui.use(['form','laydate','layer'], function(){
        var form = layui.form,
            laydate = layui.laydate,
            layer = layui.layer,
            $ = layui.jquery;
        laydate.render({
            elem: '#dealCalender'
            ,type: 'datetime'
        });
        //监听提交
        $("#submit").click(()=>{
            var userName = $('#userName').val(); //用户名
            var email = $("#email").val();
            var address = $("#address").val();
            var phone = $("#phone").val();
            var manager = $("#manager").val();
            var sex = $('input[name="sex"]:checked').val();
            $.ajax({
                url:'/yanjie/add',
                data:{"userName":userName, "email":email, "address":address, "phone":phone,"manager":manager, "sex":sex},
                success:function (data) {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            })
        })

    });
</script>

</body>